var app = getApp()
var host = app.data.host
var httpUtil = require("../utils/httpUtil.js")
var getCommentSettingUrl = host + "getCommentSetting" //评论设置
var noCommentCountUrl = host + "noCommentCount" //未评论订单数量
var getStoreUrl = host + "getStoreInfo"
var getShopImgListUrl = host + 'getShopImgList'
/**
 * 获取评论设置
 */
function getCommentSetting(cb) {
  var commentSetting = app.data.commentSetting
  if (commentSetting) {
    if (cb) cb(commentSetting)
  } else
    httpUtil.get(getCommentSettingUrl, null, res => {
      if (res.status == 0) {
        app.data.commentSetting = res.data
        if (cb) cb(res.data)
      } else {
        if (cb) cb()
      }
    })
}
//未评论订单数量
function noCommentCount(cb) {
  var data = {
    cusId: app.data.user.id
  }
  httpUtil.get(noCommentCountUrl, data, res => {
    if (res.status == 0) {
      cb(res.data)
    }
  })
}
//门店信息
function getStore(cb) {
  httpUtil.get(getStoreUrl, null, cb)
}
// 获取门店环境图
function getShopImgList(cb) {
  httpUtil.get(getShopImgListUrl, null, cb)
}
module.exports = {
  getCommentSetting: getCommentSetting,
  noCommentCount: noCommentCount,
  getStore: getStore,
  getShopImgList: getShopImgList,
}